'use strict';

const Controller = require('egg').Controller;

class WorksController extends Controller {
  async index() {
    const { ctx } = this;
    let info=ctx.request.query
// 获取缓存中的邮箱
let email = this.ctx.session.email

        // 通过用户邮箱查用户信息
    let user=`SELECT * FROM user WHERE email="${email}"`
    let userInfo = await this.app.mysql.query(user)
    // console.log(userInfo);
    // 通过用户id查书本信息

    let book=`SELECT * FROM book WHERE id="${userInfo[0].id}"`
        let bookInfo = await this.app.mysql.query(book)
        // console.log(bookInfo,2222);
        ctx.body = [userInfo,bookInfo];
  }

}

module.exports = WorksController;
